{% extends "user/layout.html.twig" %}

{% block title %}Log in - {{ parent() }}{% endblock %}

{% block user_content %}
    {% if app.user %}
        <div class="col-xs-6">
            <p>You are logged in as {{ app.user.username }}, <a href="{{ path('logout') }}">Log out</a></p>
        </div>
    {% else %}
        <div class="col-xs-12">
            <h2 class="title">
                Sign in
            </h2>
        </div>
        <div class="col-md-6">
            {% if error is defined and error is not empty %}
                <div class="alert alert-warning">
                {% if error.messageKey is defined %}
                    {{ error.messageKey|trans(error.messageData) }}
                {% else %}
                    {{ error }}
                {% endif %}
                </div>
            {% endif %}

            <form action="{{ path('login') }}" method="POST" id="page_login">
                <div class="form-group clearfix">
                    <label for="username">Username / Email</label>
                    <div class="input-group clearfix">
                        <input class="form-control" type="text" id="username" name="_username" value="{{ lastUsername|default('') }}">
                        <span class="input-group-addon"><span class="icon-user"></span></span>
                    </div>
                </div>

                <div class="form-group clearfix">
                    <label for="password">Password</label>
                    <div class="input-group clearfix">
                        <input class="form-control" type="password" id="password" name="_password">
                        <span class="input-group-addon"><span class="icon-lock"></span></span>
                    </div>
                </div>

                <div class="checkbox">
                    <a class="pull-right" href="{{ path('request_pwd_reset') }}">Forgot password?</a>

                    <label for="remember_me">
                        <input type="checkbox" id="remember_me" name="_remember_me" value="on" checked="checked" />
                        Remember me
                    </label>
                </div>

                {% if packagist_host and packagist_host in app.request.headers.get('Referer') %}
                    <input type="hidden" name="_target_path" value="{{ app.request.headers.get('Referer') }}" />
                {% endif %}

                <input class="btn btn-block btn-success btn-lg" type="submit" id="_submit" name="_submit" value="Log in" />
            </form>

            <hr>
        </div>

        <div class="clearfix"></div>

        <div class="col-md-6">
            <a class="btn btn-block btn-github btn-primary btn-lg" href="{{ path('login_github_start') }}"><span class="icon-github"></span>Log in with GitHub</a>
        </div>
    {% endif %}
{% endblock %}
